import type { FieldConfig } from '@/components/TableFilter.vue'
import { getFormFields } from '@/utils/formUtils'
import type { FormFieldConfig } from '@/types/form'

// 表格列配置
export const tableColumns = [
  {
    title: 'ID',
    dataIndex: 'id',
  },
  {
    title: '獎金名稱',
    dataIndex: 'name',
  },
  {
    title: '指定產品Teams',
    dataIndex: 'productTeams',
  },
  {
    title: '生效日期',
    dataIndex: 'validFrom',
  },
  {
    title: '截止日期',
    dataIndex: 'validTo',
  },
  {
    title: '狀態',
    dataIndex: 'status',
  },
  {
    title: '修改人',
    dataIndex: 'updatedBy',
  },
  {
    title: '操作',
    key: 'action',
    align: 'center',
  },
]
// 過濾項配置
export const filterFields: FieldConfig[] = [
  {
    name: 'name',
    label: '獎金名稱',
    type: 'input',
    placeholder: '請輸入獎金名稱',
  },
  {
    name: 'status',
    label: '狀態',
    type: 'select',
    placeholder: '請選擇狀態',
    options: [
      { value: '1', label: '啟用' },
      { value: '2', label: '禁用' },
    ],
  },
]

// 表單字段配置
const FormField: Record<string, FormFieldConfig> = {
  name: {
    label: '獎金名稱',
    type: 'input',
    placeholder: '請輸入獎金名稱',
    rules: [{ required: true, message: '請輸入獎金名稱' }],
  },
  validDate: {
    label: '有效日期',
    type: 'daterange',
    // rules: [{ required: true, message: '請選擇有效日期' }],
  },
  status: {
    label: '狀態',
    type: 'select',
    placeholder: '請選擇狀態',
    rules: [{ required: true, message: '請選擇狀態' }],
    options: [
      { key: 1, label: '啟用' },
      { key: 0, label: '禁用' },
    ],
  },
  productTeams: {
    label: '產品Teams',
    type: 'select',
    placeholder: '請選擇指定的產品Teams',
    mode: 'multiple',
    // extra: '例如:選擇Team A,即是team code 以A為前綴的所有產品',
    tooltip: '例如:選擇Team A,即是team code 以A為前綴的所有產品',
    rules: [{ required: true, message: '請選擇指定的產品Teams' }],
    options: [
      { key: 'A', label: 'Team A' },
      { key: 'B', label: 'Team B' },
      { key: 'C', label: 'Team C' },
      { key: 'D', label: 'Team D' },
      // { key: 'R1', label: 'Team R1' },
      // { key: 'R2', label: 'Team R2' },
      // { key: 'F1', label: 'Team F1' },
      // { key: 'F2', label: 'Team F2' },
      // { key: 'A1', label: 'Team A1' },
      // { key: 'A2', label: 'Team A2' },
      // { key: 'A3', label: 'Team A3' },
      // { key: 'C1', label: 'Team C1' },
      // { key: 'C2', label: 'Team C2' },
      { key: 'G', label: 'Team G' },
      { key: 'P', label: 'Team P' },
      // { key: 'P1', label: 'Team P1' },
      { key: 'T', label: 'Team T' },
      // { key: 'V1', label: 'Team V1' },
      { key: 'CN', label: 'Team CN' },
      { key: 'OTHER', label: 'Team OTHER' },
      { key: 'INVEN', label: 'Team INVEN' },
    ],
  },
}

// 創建表單字段
export const getCreteFieldConfig = (fields?: string[]) => {
  return getFormFields(FormField, fields)
}

export const getEditFieldConfig = (fields?: string[]) => {
  return getFormFields(FormField, fields)
}
